﻿<!--
 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
 PARTICULAR PURPOSE.

 Copyright (c) Microsoft Corporation. All rights reserved
-->
<local:HiloPage
    x:Name="pageRoot"
    x:Uid="Page"
    x:Class="Hilo.RotateImageView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Hilo"
    xmlns:common="using:Hilo.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    DataContext="{Binding Source={StaticResource ViewModelLocator}, Path=RotateImageVM}">

    <Page.Resources>
        <common:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </Page.Resources>

    <Grid x:Name="ContentRoot" 
          d:DataContext="{Binding Source={d:DesignInstance Type=local:DesignTimeData, IsDesignTimeCreatable=True}}"
          Background="{StaticResource HiloPageBackgroundBrush}">

        <!-- Rotate Image -->
        <Grid x:Name="RotateImageGrid"
              Margin="50,50,50,110">
            <Image x:Name="Photo" 
                   AutomationProperties.AutomationId="ImageControl" 
                   HorizontalAlignment="Center"
                   ManipulationMode="Rotate"
                   Margin="{Binding ImageMargin}"
                   RenderTransformOrigin="0.5, 0.5"
                   Source="{Binding Photo.Image}"  
                   VerticalAlignment="Center">
                <Image.RenderTransform>
                    <RotateTransform 
                        x:Name="ImageRotateTransform"  
                        Angle="{Binding RotationAngle}" />
                </Image.RenderTransform>
            </Image>
            <ProgressRing IsActive="{Binding InProgress}" 
                          Foreground="{StaticResource HiloHighlightBrush}"
                          Height="60"
                          Width="60"/>
        </Grid>

        <Grid x:Name="SnappedRotateImageGrid"
              Margin="20,50,20,0"
              Visibility="Collapsed">
            <TextBlock x:Name="PageTitle"
                       x:Uid="RotateImagePageTitle"
                       Style="{StaticResource SnappedPageHeaderTextStyle}"
                       VerticalAlignment="Top"/>
            <Image x:Name="SnappedPhoto" 
                   AutomationProperties.AutomationId="SnappedImageControl" 
                   HorizontalAlignment="Center"
                   RenderTransformOrigin="0.5,0.5"
                   Source="{Binding Photo.Image}" 
                   VerticalAlignment="Center">
                <Image.RenderTransform>
                    <RotateTransform x:Name="SnappedImageRotateTransform"
                                     Angle="{Binding RotationAngle}" />
                </Image.RenderTransform>
            </Image>
        </Grid>

        <VisualStateManager.VisualStateGroups>
            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RotateButton"
                                                       Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RotateButtonPortrait"
                                                       Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="CancelButton"
                                                       Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="CancelButtonNoLabel"
                                                       Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SaveButton"
                                                       Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SaveButtonNoLabel"
                                                       Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RotateButton"
                                                       Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RotateButtonNoLabel"
                                                       Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="CancelButton"
                                                       Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="CancelButtonNoLabel"
                                                       Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SaveButton"
                                                       Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RotateImageGrid"
                                                       Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SnappedRotateImageGrid"
                                                       Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>

    <local:HiloPage.BottomAppBar>
        <AppBar x:Name="EditImageBottomAppBar" 
                x:Uid="AppBar"
                AutomationProperties.AutomationId="RotateImageBottomAppBar"
                IsOpen="True"
                IsSticky="{Binding IsAppBarSticky}" 
                Padding="10,0,10,0">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <StackPanel HorizontalAlignment="Left" 
                            Orientation="Horizontal"
                            Grid.Column="0">
                    <Button x:Name="RotateButton"
                            x:Uid="RotateAppBarButton"
                            Command="{Binding RotateCommand}" 
                            Style="{StaticResource RotateAppBarButtonStyle}" 
                            Tag="Rotate" />
                    <Button x:Name="RotateButtonNoLabel" 
                            Command="{Binding ResumeRotateCommand}" 
                            Style="{StaticResource RotateAppBarButtonNoLabelStyle}" 
                            Tag="Resume rotate"
                            Visibility="Collapsed">
                        <ToolTipService.ToolTip>
                            <ToolTip x:Uid="ResumeRotateAppBarButtonToolTip" />
                        </ToolTipService.ToolTip>
                    </Button>
                    <Button x:Name="RotateButtonPortrait"
                            Command="{Binding RotateCommand}"
                            Style="{StaticResource RotateAppBarButtonNoLabelStyle}"
                            Tag="Rotate"
                            Visibility="Collapsed">
                        <ToolTipService.ToolTip>
                            <ToolTip x:Uid="RotateAppBarButtonToolTip" />
                        </ToolTipService.ToolTip>
                    </Button>
                </StackPanel>
                <StackPanel HorizontalAlignment="Right" 
                            Orientation="Horizontal"
                            Grid.Column="1">
                    <Button x:Name="CancelButton"
                            x:Uid="CancelAppBarButton"
                            Command="{Binding CancelCommand}" 
                            Style="{StaticResource CancelAppBarButtonStyle}" 
                            Tag="Cancel" />
                    <Button x:Name="CancelButtonNoLabel"
                            Command="{Binding CancelCommand}"
                            Style="{StaticResource CancelAppBarButtonNoLabelStyle}"
                            Tag="Cancel"
                            Visibility="Collapsed">
                        <ToolTipService.ToolTip>
                            <ToolTip x:Uid="CancelRotateAppBarButtonToolTip" />
                        </ToolTipService.ToolTip>
                    </Button>
                    <Button x:Name="SaveButton"
                            x:Uid="AcceptAppBarButton"
                            Command="{Binding SaveCommand}" 
                            Style="{StaticResource AcceptAppBarButtonStyle}"
                            Tag="Save" />
                    <Button x:Name="SaveButtonNoLabel"
                            Command="{Binding SaveCommand}"
                            Style="{StaticResource AcceptAppBarButtonNoLabelStyle}"
                            Tag="Save"
                            Visibility="Collapsed">
                        <ToolTipService.ToolTip>
                            <ToolTip x:Uid="AcceptRotateAppBarButtonToolTip" />
                        </ToolTipService.ToolTip>
                    </Button>
                </StackPanel>
            </Grid>
        </AppBar>
    </local:HiloPage.BottomAppBar>
</local:HiloPage>

